<script setup>
import VideoData from './views/VideoData.vue'
import VideoDataImage from './views/VideoDataImage.vue'
import WebglVue from './views/Webgl.vue'
import ShowList from './views/ShowList.vue'
import TopNav from './views/TopNav.vue'
import { mainStore } from '@store'

const store = mainStore()

const closeImage = () => {
  store.showPerceivedEffectImageData = {
    show: false,
    data: null,
    name: '',
  }

  store.captureData = {
    show: false, // 显示框选区域
    showBtn: false, // 显示生成图片按钮
  }
}
</script>

<template>
  <div class="perceivedEffect-container">
    <!-- 头部 -->
    <div class="top">
      <TopNav />
    </div>

    <!-- 下半部分 -->
    <div class="buttom" :key="store.relaodPerceivedEffect">
      <!-- 展示数据左边 -->
      <div class="showWebglAndList" v-if="store.showBtnInfo[1] || store.showBtnInfo[2]">
        <div class="webgl" v-if="store.showBtnInfo[1] == true">
          <WebglVue></WebglVue>
        </div>

        <!-- 表格信息 -->
        <div class="tableList" :key="store.showBtnInfo[1]" v-if="store.showBtnInfo[2] == true" :style="{ height: store.showBtnInfo[1] ? '300px' : '700px', width: store.showBtnInfo[3] ? '950px' : '100%' }">
          <ShowList v-if="store.showPerceivedEffectInfo" />
        </div>
      </div>

      <!-- 展示数据右边 -->
      <div class="showVideo" v-if="store.showBtnInfo[3] == true">
        <!-- <VideoData /> -->
        <VideoDataImage />
      </div>
    </div>

    <!-- 感知截图下载的预览 -->
    <el-dialog v-model="store.showPerceivedEffectImageData.show" :show-close="false" title="Warning" width="500" align-center @close="closeImage">
      <template #header="{ close, titleId, titleClass }">
        <div class="my-header">
          <p>下载成功 请到浏览器下载中查看 图片名 {{ store.showPerceivedEffectImageData.name }}</p>
          <img src="/public/global/close_1.png" @click="closeImage" draggable="false" />
        </div>
      </template>
      <div class="showImg">
        <img :src="store.showPerceivedEffectImageData.data" draggable="false" />
      </div>
    </el-dialog>
  </div>
</template>

<style lang="less" scoped>
.perceivedEffect-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#tipText {
  width: 116px;
  height: 44px;
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 99;
  background-color: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
}

.top {
  width: 100%;
  height: 40px;
  background-color: #eee;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.buttom {
  flex: 1;
  display: flex;
  box-sizing: border-box;
  flex-shrink: 0;
}

.showWebglAndList {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;

  .webgl {
    flex: 1;
    width: 100%;
    padding: 10px 10px;
  }

  .tableList {
    padding: 0 10px 10px 10px;
  }
}

.showVideo {
  flex: 1;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
}

.my-header {
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(122, 199, 86, 0.2);
  color: rgb(122, 199, 86);
  font-size: 14px;
  padding-left: 12px;
  img {
    width: 16px;
    height: 16px;
    margin-right: 10px;
    cursor: pointer;
  }
}

.showImg {
  height: 400px;
  width: 100%;
  img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
}
</style>
